home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / TIME_ZON / CNOBJECT.C < prev    next >
Text File  |  1991-11-08  |  2KB  |  116 lines

  1. /* CNObject.c
  2.  *    This object has a name.
  3.  */
  4.  
  5. #include "CNObject.h"
  6. #include <string.h>
  7.  
  8. char    gNextChar = 'A';
  9.  
  10. void
  11. CNObject::INObject()
  12. {
  13.         /*
  14.          * Okay, so it's not named yet.
  15.          */
  16.  
  17.     name[0] = '\0';
  18. }
  19.  
  20.  
  21. void
  22. CNObject::DisposeComplete()
  23. {
  24.         /*
  25.          * In general, Dispose is sufficient. But if you need to 
  26.          * completely dump the object (even from a file where it's
  27.          * kept - see CZone) this can be overridden
  28.          */
  29.          
  30.     Dispose();
  31. }
  32.  
  33.  
  34. void
  35. CNObject::SetName(theName)
  36. char *theName;
  37. {
  38.         /*
  39.          * Copy in the new name.
  40.          */
  41.          
  42.     strncpy(name,theName,39);
  43. }
  44.  
  45.  
  46. void
  47. CNObject::GetName(theName)
  48. char *theName;
  49. {
  50.         /*
  51.          * Get a copy of the name. Note that the owner of the string
  52.          * is the caller.
  53.          */
  54.          
  55.     strcpy(theName,name);
  56. }
  57.  
  58.  
  59. int
  60. CNObject::CompareName(theName)
  61. char *theName;
  62. {
  63.         /*
  64.          * Okay, so compare them
  65.          */
  66.          
  67.     return(strcmp(theName,name));
  68. }
  69.  
  70.  
  71. Boolean
  72. CNObject::NameEquals(theName)
  73. char *theName;
  74. {
  75.         /*
  76.          * Are these exactly equal?
  77.          */
  78.          
  79.     return(strcmp(theName,name) == 0);
  80. }
  81.  
  82.  
  83. Boolean
  84. CNObject::PartEquals(theName)
  85. char *theName;
  86. {
  87.         /*
  88.          * Are these equal to the length of the input string?
  89.          */
  90.          
  91.     return(strncmp(theName,name,strlen(theName)) == 0);
  92. }
  93.  
  94.  
  95. Boolean
  96. CNObject::NameGreater(theName)
  97. char *theName;
  98. {
  99.         /*
  100.          * Is the name of the object greater than the name of the
  101.          * input string?
  102.          */
  103.          
  104.     return(strcmp(theName,name) < 0);
  105. }
  106.  
  107.  
  108. Boolean
  109. CNObject::Edit()
  110. {
  111.     /* Nothing is the default, so if the object needs to be able to
  112.      * edit itself, this should be overridden.
  113.      */
  114. }
  115.  
  116.